package com.example.demo_customer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/demo")
public class DemoCustomer {

    @Autowired
    private RestTemplate restTemplate;
    private final String providerUrl = "http://PROVIDER/demo/hi"; //连接注册中心PROVIDER服务下 /demo/hi请求

    // /pro 请求 -> 指向 PROVIDER/demo/hi 请求
    @RequestMapping("/pro")
    public String provider() {
        return restTemplate.getForObject(providerUrl, String.class);
    }

    @RequestMapping("/hi")
    public String hi() {
        return "hello,I am consumer,nice to meet you1!";
    }

}
